package com.geeke.test.delegate;

import java.util.Map;

import org.camunda.bpm.engine.delegate.DelegateExecution;

import com.geeke.camundaex.delegate.IWfData;
import com.geeke.camundaex.delegate.StartEventDelegate;
import com.geeke.sys.entity.User;
import com.geeke.sys.service.UserService;
import com.geeke.test.entity.Leave;
import com.geeke.utils.SpringUtils;

public class LeaveStartDelegate extends StartEventDelegate {

    @Override
    protected IWfData createWfData(DelegateExecution execution) {
        // 1. 流程变量读写
        // 获取所有流程变量
        Map<String, Object> variables = execution.getVariables();
        // 获取当个对象值
        String formId = (String)execution.getVariable("formId");
        // 设置流程变量
        execution.setVariable("myKey", 123);
        
        // 2. 获取spring bean
        UserService userService = SpringUtils.getBean(UserService.class);


        // 3. 构建表单对象，并且返回
        Leave leave = new Leave();
        leave.setLeaver(new User("1000"));
        leave.setName("定时发起的请假");
        leave.setDays(3.0);
        return leave;
    }
}
